<template>
  <view :style="{ height: screenHeight + 'px', width: screenWidth + 'px' }">
    <template v-if="isPayed">
      <!--  已支付状态       -->
      <ContentUnLockFirstPage :itemObj="itemObj" :pageIndex="index" v-show="index % 3 == 0"
        @setCurrentPage="setCurrentPage" />
      <ContentUnLockSecPage :itemObj="itemObj" v-show="index % 3 > 0" :pageIndex="index"
        @setCurrentPage="setCurrentPage" />
    </template>

    <template v-else>
      <!-- 未支付状态        -->
      <ContentLockFirstPage :itemObj="itemObj" @clickUnlock="handleUnlock" @clickCodeUnlock="openCodeInputDialog"
        :pageIndex="index" v-show="index % 3 == 0" @setCurrentPage="setCurrentPage" />
      <ContentLockSecPage :itemObj="itemObj" @clickUnlock="handleUnlock" @clickCodeUnlock="openCodeInputDialog"
        :pageIndex="index" v-show="index % 3 == 1" @setCurrentPage="setCurrentPage" />
      <ContentLockThreePage :itemObj="itemObj" @clickUnlock="handleUnlock" @clickCodeUnlock="openCodeInputDialog"
        :pageIndex="index" v-show="index % 3 == 2" @setCurrentPage="setCurrentPage" />
    </template>
  </view>
</template>

<script>
import ContentLockThreePage from "./ContentLockThreePage.vue";
import ContentLockSecPage from "./ContentLockSecPage.vue";
import ContentLockFirstPage from "./ContentLockFirstPage.vue";
import ContentUnLockFirstPage from "./ContentUnLockFirstPage.vue";
import ContentUnLockSecPage from "./ContentUnLockSecPage.vue";
export default {
  props: {
    index: {
      type: Number,
      default: 0,
    },

    isPayed: {
      type: Boolean,
      default: false,
    },

    itemObj: {
      type: Object,
      default: function () {
        return {
          // 剩余简历诊断解锁次数
          unLockNum: 0,
          // 总共简历诊断解锁次数
          totalUnLockNum: 0,
        };
      },
    },
  },

  components: {
    ContentLockFirstPage,
    ContentUnLockFirstPage,
    ContentLockSecPage,
    ContentLockThreePage,
    ContentUnLockSecPage,
  },
  data() {
    return {
      screenHeight: 0,
      screenWidth: 0,
    };
  },

  onReady() {
    let systemInfo = uni.getSystemInfoSync();
    this.screenHeight = systemInfo.windowHeight;
    this.screenWidth = systemInfo.windowWidth;
  },
  watch: {
    itemObj: {
      handler(val) {
        if (val.isLock) {
        }
      },

      deep: true, // 深度监听
      immediate: true, // 初始化的时候立刻执行一次
    },
  },

  methods: {
    setCurrentPage(page) {
      this.$emit("setCurrentPage", page);
    },

    handleUnlock() {
      // 点击解锁
      this.$emit("clickUnlock", {});
    },
    clickCodeUnlock() {
      // 点击激活码
      this.$emit("openCodeInputDialog", {});
    },
  },
};
</script>
<style  lang="scss" scoped>
</style>